bitkeeper revision 1.639 (3fccbe07JV6j1aK3O8_w92nf6uQSBw)
authoriap10@labyrinth.cl.cam.ac.uk <iap10@labyrinth.cl.cam.ac.uk>
Tue, 2 Dec 2003 16:29:59 +0000 (16:29 +0000)
committeriap10@labyrinth.cl.cam.ac.uk <iap10@labyrinth.cl.cam.ac.uk>
Tue, 2 Dec 2003 16:29:59 +0000 (16:29 +0000)
Misc improvements to pincpu stuff.

.rootkeys
tools/examples/destroydom.py [changed mode: 0644->0755]
tools/examples/listdoms.py [changed mode: 0644->0755]
tools/examples/mynewdom.py
tools/examples/pincpu.py
tools/examples/startdom.py [new file with mode: 0755]
tools/examples/stopdom.py [changed mode: 0644->0755]
tools/xc/py/XenoUtil.py
xen/common/dom0_ops.c

index f5af9fa9213cb6c1d84f7cbed92b9cf854340204..b3264c981129478943861a775d567bbc24164e8a 100644 (file)
--- a/.rootkeys
+++ b/.rootkeys
@@ -44,6 +44,7 @@
 3fbe2f12ltvweb13kBSsxqzZDAq4sg tools/examples/listdoms.py
 3fca7788tBihusQSq3HJI-YKQTN2iQ tools/examples/mynewdom.py
 3fca7700PVj36cZObaFZlQicRiw1pQ tools/examples/pincpu.py
+3fccbe068ov0YCxnk-2m4law19QMmA tools/examples/startdom.py
 3fbe2f12Bnt8mwmr1ZCP6HWGS6yvYw tools/examples/stopdom.py
 3f776bd2Xd-dUcPKlPN2vG89VGtfvQ tools/misc/Makefile
 3f6dc136ZKOjd8PIqLbFBl_v-rnkGg tools/misc/miniterm/Makefile
old mode 100644 (file)
new mode 100755 (executable)
old mode 100644 (file)
new mode 100755 (executable)
index 49dba2d339e87dae3103e1d5edcef8c880a05ea7..b3df7853bf9c2f9d48718c4c723f67462fadaaf6 100755 (executable)
@@ -1,8 +1,9 @@
 #!/usr/bin/env python
 
-#
-# Example script for creating and building a new Linux guest OS for Xen.
-#
+# Example script for creating and building a new Linux guest OS for
+# Xen.  THIS IS VERY SITE SPECIFIC, but shows an example configuration
+# using multiple root partitions with a common /usr.  e.g. Domain1
+# uses root /dev/sda8, usr /dev/sda6, and the next sequential IP address.
 
 import Xc, XenoUtil, sys, os, socket, re
 
@@ -19,18 +20,18 @@ memory_megabytes = 64
 # STEP 3. A handy name for your new domain.
 domain_name = "My new domain"
 
-# Allocate new domain
+# Allocate new domain ad get its domain id
 xc = Xc.new()
 id = xc.domain_create( mem_kb=memory_megabytes*1024, name=domain_name )
 if id <= 0:
     print "Error creating domain"
     sys.exit()
 
-# Set the CPU, or leave to round robin
+# Set the CPU, or leave to round robin allocation
 #xc.domain_pincpu( dom=id, cpu=1 )
 
 # STEP 4. Specify IP address, netmask and gateway for the new domain.
-ipaddr  = XenoUtil.add_to_ip(XenoUtil.addr_of_iface('eth0'),id)
+ipaddr  = XenoUtil.add_offset_to_ip(XenoUtil.get_current_ipaddr(),id)
 netmask = XenoUtil.get_current_ipmask()
 gateway = XenoUtil.get_current_ipgw()
 
index d978067d7223433b46de357a6259e20d6b711fb5..f010f249c1ac42cf3aaeda87049bc0739fe99e9d 100755 (executable)
@@ -4,7 +4,7 @@
 # Destroy specified domain.
 #
 
-import Xc, sys, re
+import Xc, sys, re, time
 
 xc = Xc.new()
 
@@ -12,5 +12,20 @@ if len(sys.argv) < 3:
     print "Specify a domain identifier and CPU"
     sys.exit()
 
-xc.domain_pincpu( dom=int(sys.argv[1]), cpu=int(sys.argv[2]))
+dom = int(sys.argv[1])
+cpu = int(sys.argv[2])
+
+orig_state = xc.domain_getinfo(first_dom=dom, max_doms=1)[0]['stopped']
+
+while xc.domain_getinfo(first_dom=dom, max_doms=1)[0]['stopped'] != 1:
+    xc.domain_stop( dom=dom )
+    time.sleep(0.1)
+
+xc.domain_pincpu( dom, cpu )
+
+if orig_state == 0:
+    xc.domain_start( dom=dom )
+
+
+
 
diff --git a/tools/examples/startdom.py b/tools/examples/startdom.py
new file mode 100755 (executable)
index 0000000..0a4a53c
--- /dev/null
@@ -0,0 +1,15 @@
+#!/usr/bin/env python
+
+#
+# Start execution of specified domain.
+#
+
+import Xc, sys, re
+
+xc = Xc.new()
+
+if len(sys.argv) != 2:
+    print "Specify a domain identifier"
+    sys.exit()
+
+xc.domain_start( dom=int(sys.argv[1]) )
old mode 100644 (file)
new mode 100755 (executable)
index dfbcabc800c2e0fcf96663233ac441abbdf8dba1..c49f859f5fa8b549bfd1d9363c520bd25c51c9e7 100644 (file)
@@ -129,16 +129,11 @@ def setup_vfr_rules_for_vif(dom,vif,addr):
     os.close( fd )
     return None
 
-def addr_of_iface( iface ):
-    fd = os.popen( '/sbin/ifconfig '+iface )
-    lines = fd.readlines()
-    for line in lines:
-       m = re.search( 'inet addr:([0-9.]+)', line )
-       if m: 
-           return m.group(1)
-    return None
-
-def add_to_ip( ip, off ):
+def add_offset_to_ip( ip, off ):
     l = string.split(ip,'.')
-    return '%s.%s.%s.%d' % ( l[0],l[1],l[2],string.atoi(l[3])+off )
+    a = ( (string.atoi(l[0])<<24) | (string.atoi(l[1])<<16) | 
+         (string.atoi(l[2])<<8)  | string.atoi(l[3]) ) + off
+    
+    return '%d.%d.%d.%d' % ( ((a>>24)&0xff), ((a>>16)&0xff),
+                            ((a>>8)&0xff), (a&0xff) )
 
index 5f5e803c5a8a26b320085dfefc3807878fbb63bd..2f3073a1c4acda2309b8b22be1cf5a734a849130 100644 (file)
@@ -196,14 +196,17 @@ long do_dom0_op(dom0_op_t *u_dom0_op)
            else
              {
                /* For the moment, we are unable to move running
-               domains between CPUs. (We need a way of cleanly stopping 
-               running domains). For now, if we discover the domain is
-               running then cowardly bail out with ENOSYS */
+               domains between CPUs. (We need a way of synchronously
+               stopping running domains). For now, if we discover the
+               domain is not stopped already then cowardly bail out
+               with ENOSYS */
 
-               if(p->flags & PF_CONSTRUCTED
+               if( !(p->state & TASK_STOPPED) 
                  ret = -ENOSYS;
                else
                  {
+                   /* We need a task structure lock here!!! 
+                      FIX ME!! */
                    cpu = cpu % smp_num_cpus;
                    p->processor = cpu;
                    p->cpupinned = 1;